
<template>
  <div>
    <template v-for="(item, index) in data">
      <el-submenu :index="`sub-${item.title}`" v-if="item.children" :key="'sub' + index">
        <template slot="title">
          <i :class="item.icon" v-if="item.icon"></i>
          <span class="title">{{ item.title }}</span>
        </template>
        <Submenu :data="item.children"></Submenu>
      </el-submenu>
      <el-menu-item v-else :index="item.path" :route="{ path: item.path }" :key="index">
        <i :class="item.icon" v-if="item.icon"></i>
        <span slot="title">{{ item.title }}</span>
      </el-menu-item>
    </template>
  </div>
</template>

<script>
export default {
  name: 'Submenu',
  props: {
    data: {
      type: Array,
      default: () => []
    }
  }
};
</script>
<style lang="scss" scoped>
.el-menu {
  &.el-menu--collapse {
    .el-submenu__title {
      .title {
        display: none;
      }
    }
  }
}
/deep/.el-submenu__icon-arrow.el-icon-arrow-right {
  display: none !important;
}
</style>
